Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove eth-account deprecation warnings #1468

Merged
merged 1 commit into from
Oct 17, 2019

Conversation

kclowes
Copy link
Collaborator

@kclowes kclowes commented Oct 4, 2019

What was wrong?

There were lots of deprecation warnings from eth-account when the tests were run.

How was it fixed?

Began using the new eth-account methods that were introduced.

Todo:

Cute Animal Picture

image

@kclowes
Copy link
Collaborator Author

kclowes commented Oct 4, 2019

@carver or @pipermerriam I am not sure why encode_defunct is working for text in this test but not for the bytes values in this test. Can you see what I'm doing wrong?

@pipermerriam
Copy link
Member

@kclowes taking a look at the source code for those two functions it doesn't appear they can be swapped 1:1. Looks like the return value from encode_defunct is a SignableMessage type where-as the previous defunct_hash_message returns a 32-byte message hash. You'll either have to update the assertions or do some extra lifting to the get message hash.

@MatthiasLohr
Copy link
Contributor

Having these fixed would be really nice! Can I help somehow?

@kclowes
Copy link
Collaborator Author

kclowes commented Oct 8, 2019

@MatthiasLohr I am at Devcon and probably won't have time to get to this PR this week so feel free to pick it up. I think fixing those last few failing tests are what's left to do!

@kclowes kclowes changed the title [WIP] Remove some deprecation warnings Remove eth-account deprecation warnings Oct 16, 2019
Copy link
Member

@pipermerriam pipermerriam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you verified that you've bumped the eth-account dependency sufficiently high to ensure these new APIs are present?

@kclowes
Copy link
Collaborator Author

kclowes commented Oct 17, 2019

Good thought! Yep, eth-account is bumped to 0.4.0 which has these new APIs 👍

@kclowes kclowes merged commit 724b0f5 into ethereum:master Oct 17, 2019
@kclowes kclowes deleted the change-to-from-key branch October 17, 2019 20:00
Copy link
Collaborator

@carver carver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MInor rename suggestion due to the change in the message-signing API.

message_hash = defunct_hash_message(text=message)
from_account = acct.recoverHash(message_hash, vrs=(v, r, s))
message_hash = encode_defunct(text=message)
from_account = acct.recover_message(message_hash, vrs=(v, r, s))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since encode_defunct returns a (signable) message now, the variable name should probably be changed from message_hash. Maybe signable_message, encoded_message or encoded is a reasonable name now.

Another very reasonable option is to rename message => message_text, and message_hash => message. (this might by my favorite)

from_account = acct.recoverHash(msg_hash, signature=signature_bytes)
assert from_account == '0xFeC2079e80465cc8C687fFF9EE6386ca447aFec4'
msg_hash = encode_defunct(b'\xbb\r\x8a\xba\x9f\xf7\xa1<N,s{i\x81\x86r\x83{\xba\x9f\xe2\x1d\xaa\xdd\xb3\xd6\x01\xda\x00\xb7)\xa1') # noqa: E501
from_account = acct.recover_message(msg_hash, signature=signature_bytes)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, msg_hash is an inaccurate variable name now.

from_account = acct.recoverHash(msg_hash, vrs=map(to_hex, (v, r, s)))
assert from_account == '0xFeC2079e80465cc8C687fFF9EE6386ca447aFec4'
msg_hash = encode_defunct(b'\xbb\r\x8a\xba\x9f\xf7\xa1<N,s{i\x81\x86r\x83{\xba\x9f\xe2\x1d\xaa\xdd\xb3\xd6\x01\xda\x00\xb7)\xa1') # noqa: E501
from_account = acct.recover_message(msg_hash, vrs=(v, r, s))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

from_account = acct.recoverHash(msg_hash, vrs=(v, r, s))
assert from_account == '0xFeC2079e80465cc8C687fFF9EE6386ca447aFec4'
msg_hash = encode_defunct(b'\xbb\r\x8a\xba\x9f\xf7\xa1<N,s{i\x81\x86r\x83{\xba\x9f\xe2\x1d\xaa\xdd\xb3\xd6\x01\xda\x00\xb7)\xa1') # noqa: E501
from_account = acct.recover_message(msg_hash, vrs=(v, r, s))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -230,18 +231,22 @@ def test_eth_account_recover_vrs_standard_v(acct):
ids=['web3js_example', '31byte_r_and_s'],
)
def test_eth_account_sign(acct, message, key, expected_bytes, expected_hash, v, r, s, signature):
message_hash = defunct_hash_message(text=message)
assert message_hash == expected_hash
message_hash = encode_defunct(text=message)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants